layui.use(['jquery','laydate','layer','form','table'],function () {
    var $ = layui.jquery;
    var laydate = layui.laydate;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;

    laydate.render({
        elem:"#unsealDate",
        type:"date",
        tigger:"click"
    });
    var account ="";
    var deptName = "";
    var unsealDate="";
    select(account,deptName,unsealDate);
    function select(account,deptName,unsealDate) {
        table.render({
            elem:"#root",
            url:"/JsPeopleUnsealingLog/SelectPeopleUnsealing?account="+account+"&deptName="+deptName+"&unsealDate="+unsealDate,
            toolbar:"#toptool",
            page:true,
            limit:5,
            limits:[5,10,15,20],
            size: 'lg',
            cols:[[
                {type:"checkbox",align:"center"},
                {type:"numbers",title:"序号",align:"center"},
                {field:"account",title:"账户名称",align:"center"},
                {field:"deptName",title:"部门名称",align:"center"},
                {field:"type",title:"用户类型",align:"center",templet:function (data) {
                    if(data=2){
                        return "后台用户";
                    }
                    }},
                {field:"unsealDate",title:"解封时间",align:"center"},
                {title:"操作",align:"center",templet:function (data) {
                        return "<div>"+
                            "<a href='javascript:chakan(" + data.userId + ");' style='color: #0EAA9E;margin-right: 10px'>查看</a>" +
                            "</div>";
                    }}
            ]]
        })
    };

    //查看用户信息
    chakan = function chakan(userId){
        $.ajax({
            type:"post",
            dataType:"json",
            data:{"id":userId},
            url:"/JsPeopleList/selectJsUserById",
            success:function (data) {
                cha(data);
            }
        })
    };
    //查看后弹出赋值
    function cha(data) {
        var obj;
        layer.open({
            type:2,
            shode:0,
            maxmin:true,
            title:"查看用户信息",
            content:"/jurisdiction/jurisdiction-see-uesr.html",
            area:["1000px","620px"],
            btn:["关闭"],
            yes:function (index) {
                layer.close(index);
            },success:function (layero,index) {
                obj = layero.find('iframe').contents();
                obj.find("#acatarUrl").attr('src',data.data.acatarUrl);
                obj.find("#account").val(data.data.account);
                obj.find("#trueName").val(data.data.trueName);
                obj.find("#sex").val(data.data.sex);
                obj.find("#phone").val(data.data.phone);
                obj.find("#birthDate").val(data.data.birthDate);
                obj.find("#deptName").val(data.data.deptName);
                obj.find("#registerDate").val(data.data.registerDate);
                obj.find("#registerIp").val(data.data.registerIp);
                obj.find("#email").val(data.data.email);
                obj.find("#freestyle").val(data.data.freestyle);
            }
        });
    };
    //搜索
    $("#sousuo").click(function () {
        var account = $("#account").val();
        var deptName = $("#deptName").val();
        var unsealDate = $("#unsealDate").val();
        select(account,deptName,unsealDate);
    });
    //重置
    $("#chongzhi").click(function () {
        select(account,deptName,unsealDate);
    });
    $("#shuaxin").click(function () {
        location.reload();
    });
    //跳转
    goBack=function goBack(){
        //通过页面查找iframe
        parent.$('#recordLog').val($('#examine').text());
        parent.before();
        return false;
    };
});